﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.UI.Selection;

namespace demansion
{

    [Transaction(TransactionMode.Manual)]
    [Regeneration(RegenerationOption.Manual)]    
    public class auto:IExternalCommand
    {
        Result  IExternalCommand.Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
           

                    try
                    {
                    UIDocument uidoc = commandData.Application.ActiveUIDocument;
                    Selection selection = uidoc.Selection;
                    ElementSet collection = selection.Elements;
                    string strMessage = null;
                    Reference eRef = selection.PickObject(ObjectType.Element, strMessage);
                    Dimension selected;
                    if (eRef != null && eRef.Element != null)
                    {
                        selected = eRef.Element as Autodesk.Revit.DB.Dimension;
                        TaskDialog dd = new TaskDialog("dd");
                        dd.MainContent = selected.Name;
                        dd.Show();
                    }
                    else {

                        TaskDialog dd = new TaskDialog("dd");
                        dd.MainContent = "错误";
                        dd.Show();
                    
                    }

                    }
                    catch (Exception e)
                    {
                        message = e.Message;
                    }


            return Result.Succeeded;

        }

    }
}
